package com.glsc.ngateway.common.base.repo.mysql.cmdb;

import com.glsc.ngateway.common.base.domain.mysql.cmdb.CmdbMemoryStandardDeviceStandardRelate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface CmdbMemoryStandardDeviceStandardRelateRepository extends JpaRepository<CmdbMemoryStandardDeviceStandardRelate, Integer>, JpaSpecificationExecutor<CmdbMemoryStandardDeviceStandardRelate> {
    List<CmdbMemoryStandardDeviceStandardRelate> findAllByIdIn(List<Long> id);

    @Transactional
    @Modifying
    @Query(value = "update t_cmdb_memory_standard_device_standard_relate set is_delete = :deleted where id in :codes ", nativeQuery = true)
    void updateIsDeleteByCodes(Integer deleted, List<Integer> codes);

    @Transactional
    @Modifying
    @Query(value = "update t_cmdb_memory_standard_device_standard_relate set is_delete = :deleted where device_standard_code = :deviceStandardCode ", nativeQuery = true)
    void updateIsDeleteByDeviceStandardCode(Integer deleted, String deviceStandardCode);

    CmdbMemoryStandardDeviceStandardRelate findOneByDeviceStandardCodeAndIsDelete(String deviceStandardCode, Integer isDelete);

//    Page<CmdbMemoryStandardDeviceStandardRelate> searchByParam(Pageable pageable, CmdbMemoryStandardDeviceStandardRelate paramSearchDto);
}

